怎么用VB求[(1+2+3+...+M)+(1+2+3+...+N)]/(1+2+3+...+P)

来源:百度知道 编辑:UC知道 时间:2024/05/05 03:23:11
要求用两种方法,其中一种是Sub过程

Sub AAA(M as Integer,N as Integer,P as Integer,R as Double)
S=0
For i=1 to M
S=S+i
Next
For i=1 to n
S=S+i
Next
R=S
S=0
For i=1 to P
S=S+i
Next
R=R/S
End Sub

Private Sub Form_Click()
Dim R as Double
Call AAA(5,7,3,R)
Print R
End Sub

'方法二:---------------------------------
Function Sum(N as Integer) as long
For i=1 to N
Sum=Sum+N
Next
End Function

Private Sub Form_Click()
Dim M as Integer,N as Integer,P as Integer
M=5
N=6
P=7
Print (Sum(M)+Sum(N))/Sum(p)
End Sub